const path = require("path");
const Koa = require("koa");

const parameter = require("koa-parameter");
const { koaBody } = require("koa-body");
const KoaStatic = require("koa-static");
const cors = require("@koa/cors");
const router = require("../routes/index.js");
let app = new Koa();
app.use(cors());
parameter(app);
app.use(
  koaBody({
    multipart: true,
    formidable: {
      uploadDir: path.join(__dirname, "../uploads"),
      keepExtensions: true,
    },
  })
);

app.use(KoaStatic(path.join(__dirname, "../uploads")));

app.use(router.routes()).use(router.allowedMethods());
module.exports = app;
